package com.wp.design.create.singleton.hungrysingleton;

import java.io.Serializable;

public class HungrySingleton implements Serializable{
	private final static HungrySingleton HUNGRY_SINGLETON = new HungrySingleton();

	private HungrySingleton() {
		if (HUNGRY_SINGLETON != null){
			throw new RuntimeException("不允许使用反射创建");
		}
	}

	public static HungrySingleton getInstance(){
		return HUNGRY_SINGLETON;
	}

	/**
	 * 防止序列化后，对象实例发生变化
	 * @return
	 */
	public Object readResolve(){
		return HUNGRY_SINGLETON;
	}
}
